//
//  GFLcTableViewCell.m
//  Qyer
//
//  Created by dlios on 15/10/22.
//  Copyright (c) 2015年 GF. All rights reserved.
//

#import "GFLcTableViewCell.h"

@implementation GFLcTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _image = [[UIImageView alloc]initWithFrame:CGRectMake(5 * WIDTH, 5 * HEIGHT, SCREEN_WIDTH - 10 * WIDTH, 150 * HEIGHT)];
        [self.contentView addSubview:_image];
        [_image setUserInteractionEnabled:YES];
        
        UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressClick)];
        [_image addGestureRecognizer:longPress];
        
        _nameLable = [[UILabel alloc] initWithFrame:CGRectMake(5 * HEIGHT, 130 * HEIGHT, SCREEN_WIDTH - 10 * WIDTH, 20 * HEIGHT)];
        [_nameLable setFont:[UIFont systemFontOfSize:WIDTH * 14.]];
        [_nameLable setBackgroundColor:[UIColor clearColor]];
        [_nameLable setTextColor:[UIColor blackColor]];
        [_image addSubview:_nameLable];
        
        _descriptionLable = [[UILabel alloc] initWithFrame:CGRectZero];
        [_descriptionLable setFont:[UIFont systemFontOfSize:WIDTH * 16.]];
        [_descriptionLable setBackgroundColor:[UIColor clearColor]];
        [_descriptionLable setNumberOfLines:0];
        [_descriptionLable setTextColor:[NightMode shareNightModeHandle].wordColor];
        [self.contentView addSubview:_descriptionLable];
    }
    return self;
}

- (void)getJnModel:(GFJnModel *)model{
    [_image sd_setImageWithURL:[NSURL URLWithString:model.image_url] placeholderImage:[UIImage imageNamed:@"ZW.PNG"]];
    [_nameLable setText:model.name];
    [_descriptionLable setFrame:CGRectMake(5 * WIDTH, 155 * HEIGHT, SCREEN_WIDTH - 10 * WIDTH, model.height)];
    [_descriptionLable setText:model.des];
}

- (void)longPressClick{
//   UIImageWriteToSavedPhotosAlbum(_image,self,@selector(image:didFinishSavingWithError:contextInfo:),NULL);
}
- (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
    NSString *message = @"呵呵";
    if (!error) {
        message = @"成功保存到相册";
    }else
    {
        message = [error description];
    }
    NSLog(@"message is %@",message);
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
